Clover coverage report - bexee - 0.1
Coverage timestamp: Do Dez 16 2004 13:24:06 CET
file stats: LOC: 63   Methods: 2
NCLOC: 24   Classes: 1
30 day Evaluation Version distributed via the Maven Jar Repository. Clover is not free. You have 30 days to evaluate it. Please visit http://www.thecortex.net/clover to obtain a licensed version of Clover
 
 Source file Conditionals Statements Methods TOTAL
BooleanUtils.java 100% 100% 100% 100%
coverage
 1   
 /*
 2   
  * $Id: BooleanUtils.java,v 1.1 2004/12/15 14:18:20 patforna Exp $
 3   
  *
 4   
  * Copyright (c) 2004 Patric Fornasier, Pawel Kowalski
 5   
  * Berne University of Applied Sciences
 6   
  * School of Engineering and Information Technology
 7   
  * All rights reserved.
 8   
  */
 9   
 package bexee.util;
 10   
 
 11   
 import bexee.model.InvalidValueException;
 12   
 
 13   
 /**
 14   
  * Utility class for boolean values. This class provides methods for the
 15   
  * transformation of String values into boolean values.
 16   
  * 
 17   
  * @version $Revision: 1.1 $, $Date: 2004/12/15 14:18:20 $
 18   
  * @author Pawel Kowalski
 19   
  */
 20   
 public class BooleanUtils {
 21   
 
 22   
     private static final String INVALID_VALUE_EXCEPTION_STRING = "Value must be a \"YES\" or a \"NO\" String";
 23   
 
 24   
     /**
 25   
      * Transform a "YES" or "NO" string to a boolean value. This method returns
 26   
      * a "true" if the parameter String is "YES" in any other case, a "false"
 27   
      * will be returned.
 28   
      * 
 29   
      * @param yesOrNoString
 30   
      * @return a boolean value
 31   
      */
 32  48
     public static boolean yesNoToBoolean(String yesOrNoString) {
 33  48
         if (yesOrNoString != null) {
 34  8
             return yesOrNoString.equalsIgnoreCase("YES");
 35   
         } else {
 36  40
             return false;
 37   
         }
 38   
     }
 39   
 
 40   
     /**
 41   
      * Transform a "YES" or "NO" string to a boolean value. If the parameter
 42   
      * string doesn't match a "YES" or "NO" string (ignoring the case) this
 43   
      * method will throw an InvalidValueException.
 44   
      * 
 45   
      * @param yesOrNoString
 46   
      * @return @throws
 47   
      *         InvalidValueException
 48   
      */
 49  322
     public static boolean strictYesNoToBoolean(String yesOrNoString)
 50   
             throws InvalidValueException {
 51   
 
 52  322
         try {
 53  322
             if (yesOrNoString.equalsIgnoreCase("YES")) {
 54  54
                 return true;
 55  4
             } else if (yesOrNoString.equalsIgnoreCase("NO")) {
 56  2
                 return false;
 57   
             }
 58   
         } catch (NullPointerException e) {
 59  264
             throw new InvalidValueException(INVALID_VALUE_EXCEPTION_STRING, e);
 60   
         }
 61  2
         throw new InvalidValueException(INVALID_VALUE_EXCEPTION_STRING);
 62   
     }
 63   
 }